﻿using Mes.Domain.BoundedContext.EntityBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Domain.BoundedContext.Entities.WorkOrders
{
    /// <summary>
    /// 产量实体
    /// Collects item production and reject transactions by job, shift, lot etc. 
    /// </summary>
    public class ItemProd : NoIdEntityBase
    {
        /// <summary>
        /// 工单编号
        /// Identify WO
        /// </summary>
        public string Wo_Id { get; set; } = string.Empty;

        /// <summary>
        /// 操作编号
        /// Identify operation
        /// </summary>
        public string Oper_Id { get; set; } = string.Empty;

        /// <summary>
        /// 排班开始Utc时间
        /// Timestamp of shift start
        /// </summary>
        public DateTime Shift_Start_Utc { get; set; }

        /// <summary>
        /// 排班开始本地时间
        /// Timestamp of shift start
        /// </summary>
        public DateTime Shift_Start_Local { get; set; }

        /// <summary>
        /// 产品记录的开始小时UTC时间
        /// Timestamp of item prod record hour start
        /// </summary>
        public DateTime Hour_Start_Utc { get; set; }

        /// <summary>
        /// 产品记录的开始小时本地时间
        /// Timestamp of item prod record hour start
        /// </summary>
        public DateTime Hour_Start_Local { get; set; }

        /// <summary>
        /// 物料ID
        /// Item identifier
        /// </summary>
        public int Item_Id { get; set; }

        /// <summary>
        /// 批号
        /// Lot number
        /// </summary>
        public string? Lot_No { get; set; }

        /// <summary>
        /// 如需拆解，应注明生产该批原材料的批号
        /// If disassembly, lot number of raw material from which this lot was produced
        /// </summary>
        public string? Rm_Lot_No { get; set; }

        /// <summary>
        /// 物料的分批号
        /// Sublot number
        /// </summary>
        public string? Sublot_No { get; set; }

        /// <summary>
        /// 如需拆解，应注明生产该批原料的分批号
        /// If disassembly, sublot number of raw material from which this lot was produced
        /// </summary>
        public string? Rm_Sublot_No { get; set; }

        /// <summary>
        /// 生产原因
        /// Production reason
        /// </summary>
        public int Reas_Cd { get; set; } = 0;

        /// <summary>
        /// 用户ID
        /// User ID making this entry
        /// </summary>
        public string User_Id { get; set; } = String.Empty;

        /// <summary>
        /// 运行的实体
        /// On which entity job ran
        /// </summary>
        public int Ent_Id { get; set; }

        /// <summary>
        /// 排班ID
        /// Shift identifier
        /// </summary>
        public int Shift_Id { get; set; }

        /// <summary>
        /// 物料的等级编码（成品）
        /// Grade code of produced goods
        /// </summary>
        public int Grade_Cd { get; set; }

        /// <summary>
        /// 状态编号
        /// Status code of produced goods
        /// </summary>
        public int Status_Cd { get; set; }

        /// <summary>
        /// 存储位置
        /// Storage entity id for produced goods
        /// </summary>
        public int? To_Ent_Id { get; set; }

        /// <summary>
        /// 是否是良品
        /// 1 = good production, 0 = rejects
        /// </summary>
        public bool Good_Prod { get; set; }

        /// <summary>
        /// 产量
        /// Qty produced
        /// </summary>
        public double Qty_Prod { get; set; }

        /// <summary>
        /// 用于ERP的产量
        /// Qty produced txd to ERP
        /// </summary>
        public double Qty_Prod_Erp { get; set; }

        /// <summary>
        /// 这批已加工的标志
        /// Processed flag for this lot
        /// </summary>
        public int Processed_Flag { get; set; }

        /// <summary>
        /// 1 =副产品，0 =主要生产项目
        /// 1 = byproduct, 0 = main production item
        /// </summary>
        public bool Byproduct { get; set; }

        /// <summary>
        /// 参考外部系统
        /// Reference to external system 
        /// </summary>
        public string? Ext_Ref { get; set; }

        /// <summary>
        /// 这批货转移到下一个行动了吗
        /// Has this ?lot? been moved to next operation
        /// </summary>
        public int Move_Status { get; set; }

        /// <summary>
        /// PEM段内谱系ID
        /// PEM intra-segment genealogy ID
        /// </summary>
        public string? Genealogy_Id { get; set; }

        /// <summary>
        /// 事件ID
        /// PEM production event ID
        /// </summary>
        public string? Event_Id { get; set; }

        /// <summary>
        /// S95段需求ID
        /// S95 segment requirement ID
        /// </summary>
        public string? Segment_Requirement_Id { get; set; }

        /// <summary>
        /// S95段响应ID
        /// S95 segment response ID
        /// </summary>
        public string? Segment_Response_Id { get; set; }

        /// <summary>
        /// 注释
        /// Comment field
        /// </summary>
        public string? Comments { get; set; }

        /// <summary>
        /// 备用字段1
        /// Use defined by language term 691
        /// </summary>
        public string? Spare1 { get; set; }

        /// <summary>
        /// 备用字段2
        /// Use defined by language term 692
        /// </summary>
        public string? Spare2 { get; set; }

        /// <summary>
        /// 备用字段3
        /// Use defined by language term 765
        /// </summary>
        public string? Spare3 { get; set; }

        /// <summary>
        /// 备用字段4
        /// Use defined by language term 766
        /// </summary>
        public string? Spare4 { get; set; }

        /// <summary>
        /// 最新编辑原因
        /// Why record was changed
        /// </summary>
        public string? Last_Edit_Comment { get; set; }

        /// <summary>
        /// 最新编辑用户
        /// Who last changed record
        /// </summary>
        public string? Last_Edit_By { get; set; }

        /// <summary>
        /// 最新编辑时间
        /// When record last changed
        /// </summary>
        public DateTime Last_Edit_At { get; set; }= DateTime.Now;

        /// <summary>
        /// 创建UTC时间
        /// When record was created
        /// </summary>
        public DateTime Created_At_Utc { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 创建本地时间
        /// When record was created
        /// </summary>
        public DateTime Created_At_Local { get; set; } = DateTime.Now;

        /// <summary>
        /// 行ID
        /// Unique identifier for row 
        /// </summary>
        public int Row_Id { get; set; }
    }
}
